package com.stylefeng.guns.modular.system.controller;


import com.stylefeng.guns.common.controller.BaseController;
import com.stylefeng.guns.common.persistence.model.Employee;
import com.stylefeng.guns.modular.system.service.EmployeeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 前端控制器
 * @author yanqb
 * @since 2018-05-17
 */
@Controller
@RequestMapping("/employee")
public class EmployeeController extends BaseController {

    @Resource
    private EmployeeService service;

    /**
     * 跳转首页
     */
    @RequestMapping(value={""})
    public String index() {
        return "/system/employee/employee_list.html";
    }

    /**
     * 查询员工
     */
    @ApiOperation("获取员工列表")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public Object list(String condition) {
        String name = condition;
        return this.service.search(name);
    }

    /**
     * 根据id查询员工
     */
    @ApiOperation("获取员工信息")
    @RequestMapping(value = "/get/{id}", method = RequestMethod.POST)
    @ResponseBody
    public Object getEmployee(@PathVariable("id") Integer id) {
        if(id == null) id=1015;
        return this.service.getEmployee(id);
    }

}
